/**
 * Created by ZHOUSH on 3/7/2016.
 */
app.factory('layoutManager', function ($rootScope, $q, $timeout) {
    // factory function body that constructs shinyNewServiceInstance
    return {
        layoutFns: [],
        promise: [],
        push: function (layoutFn) {
            this.layoutFns.push(layoutFn);
        },
        layout: function () {
            var promises = this.layoutFns.map(function (item) {
                return $timeout(item);
            });
            $q.all(promises).then(function () {
                $rootScope.$broadcast('layoutDone');
            })
        }
    };
});